<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    <head>
        <title>KAKA</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1">
        <link href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
        <script type='text/javascript' src='/public/js/jquery-3.1.1.min.js'></script>
        <script type="text/javascript" src='/public/js/jquery.validate.js'></script>
        <script type="text/javascript" src='/public/js/main/main.js'></script>
        <script>
            var _hmt = _hmt || [];
            (function () {
                var hm = document.createElement("script");
                hm.src = "//hm.baidu.com/hm.js?8d43b5b5d798921b66d689f7a792e6e2";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
            })();
        </script>
        <script type="text/javascript">
            document.domain = '<?php echo _DOMAIN_ALL_;?>';
        </script>
        <link rel="shortcut icon" type="image/ico" href="/favicon.ico">
    </head>
    <body style="background-color: #f4f4f4">
 
<link href="/public/css/main.css" rel="stylesheet">
<script type="text/javascript">
    $(document).ready(function () {
        $('._header').width($('.container').width());
    })
</script>
<div class="container" style="background-color: white">
    <div class='_main'>
        <div class="banner">
           <!--  <div class='_logo'>
                <a href='/'><img src="/public/images/kaka.png" class='logo_img'  alt='banner'/></a>
            </div> -->
            <a href='/'><img src="/public/images/banner.png" class='banner_img'  alt='banner'/></a>
        </div>
        <div class='_header'>
            <div style='padding-right: 5rem;padding-top:1px' id="welcome">
                <span class=''><a class='_a' href="/home/passport/login"><img src="/public/images/login.png" width='90px' ></a></span>
                <span class='_span'></span>
                <span class='_span'><a class='_a' href="/home/passport/register"><img src="/public/images/register.png" width='90px' ></a></span>
            </div>
            <div style='display:none;color:white' id="already_login">
                <span class='as'><a class='_a color1' href="javascript:void(0);"><b id="login_name"></b><?php if( $msg_num != 0 ){ ?> <a href="/home/message/message"><span class="_message"><?php echo $msg_num; ?></span></a> <?php }?></a> </span>
                <span class='_span as'><b>|</b></span>
                <span class='_span' style="width:7rem"><a class='_a color1' href="/home/passport/repassword"><b>修改密码</b></a></span>
                <span class='_span as'><b>|</b></span>
                <span class='_span'><a class='_a color1' href="/home/passport/logout"><b>退出</b></a></span>
            </div>
        </div>
        <div class="_menu" id='_menu'>
            <div class='_menu_in'>
                <!-- <span class='_menu_b'>
                    <a class='wa' href="/home/company">公司</a>
                </span> -->
                <span class="<?php if(strstr(strtolower($_SERVER['REQUEST_URI']),'/home/store')){?>_menu_b_2<?php }else{?>_menu_b<?php }?>">
                    <a class="<?php if(strstr(strtolower($_SERVER['REQUEST_URI']),'/home/store')){?>_a<?php }else{?>wa<?php }?>" href='/home/store'>店铺</a>
                </span>
                <span class="<?php if(strstr(strtolower($_SERVER['REQUEST_URI']),'home/barber')){?>_menu_b_2<?php }else{?>_menu_b<?php }?>">
                    <a class="<?php if(strstr(strtolower($_SERVER['REQUEST_URI']),'/home/barber')){?>_a<?php }else{?>wa<?php }?>" href='/home/barber'>成员</a>
                </span>
                <span class="<?php if(strstr(strtolower($_SERVER['REQUEST_URI']),'/home/action')){?>_menu_b_2<?php }else{?>_menu_b<?php }?>">
                    <a class="<?php if(strstr(strtolower($_SERVER['REQUEST_URI']),'/home/action')){?>_a<?php }else{?>wa<?php }?>" href='/home/action'>活动</a>
                </span>
                <span class="<?php if(strstr(strtolower($_SERVER['REQUEST_URI']),'/home/order')){?>_menu_b_2<?php }else{?>_menu_b<?php }?>">
                    <a class="<?php if(strstr(strtolower($_SERVER['REQUEST_URI']),'/home/order')){?>_a<?php }else{?>wa<?php }?>" href='/home/order'>订单</a>
                </span>
                <span class="<?php if(strstr(strtolower($_SERVER['REQUEST_URI']),'/home/coupon')){?>_menu_b_2<?php }else{?>_menu_b<?php }?>">
                    <a class="<?php if(strstr(strtolower($_SERVER['REQUEST_URI']),'/home/coupon')){?>_a<?php }else{?>wa<?php }?>" href='/home/coupon'>优惠劵</a>
                </span>
                <span class="<?php if(strstr(strtolower($_SERVER['REQUEST_URI']),'/home/goods')){?>_menu_b_2<?php }else{?>_menu_b<?php }?>">
                    <a class="<?php if(strstr(strtolower($_SERVER['REQUEST_URI']),'/home/goods')){?>_a<?php }else{?>wa<?php }?>" href='/home/goods'>商品</a>
                </span>
            </div>
        </div>
        <div class='_line'></div>
 
<div class="_contro">
    <a href="/home/action/" class="_a"><font style='font-size:1.5rem'>返回列表页</font></a>
</div>
<div class='_cut'></div>
<div class='content'>
    <?php if($actions['id']){ ?>
    <form action="/home/action/update" method="post" id='form'>
        <?php }else{ ?>   
        <form action="/home/action/submit" method="post" id='form'>  
            <?php  }?>

            <div class='form-group row'>
                <label for="exampleInputName2" class="_label">营销模式:</label>
                <select name="type" class='_select' id='type'>
                    <?php foreach($action_type as $v){?>
                    <option value="<?php echo $v['id']; ?>" id="model_type_<?php echo $v['id']; ?>" url="<?php echo $v['link']; ?>" <?php if( $v['id'] == 2 ){echo "selected='selected'";}?>><?php echo $v['model_name'];?></option>
                    <?php } ?>
                </select>
                <?php foreach($action_type as $v){ ?>
                <input type='hidden' id="model_<?php echo $v['id'];?>" value="<?php if($actions['model_type']==$v['id']){echo $actions['intro'];}else{echo $v['intro'];}?>"/>
                <?php } ?>
            </div>

            <div>
                <div class="form-group row">
                    <label for="exampleInputName2" class="_label" >店铺:</label>
                    <select id="store_id" name="store_id">
                        <option value='0'>全部</option>
                        <?php foreach($store as $v){?>
                        <option value='<?php echo $v['id'];?>' <?php if($actions['store_id']==$v['id']){echo "selected='selected'";}?>><?php echo $v['name'];?></option>
                        <?php }?>
                    </select>
                </div>
            </div>
            <div class='form-group row'>
                <label for="exampleInputName2" class="_label">活动名称:</label>
                <?php if(!empty($actions)){?>
                <input type="text" class="row _minput" name='action_name' placeholder="" value="<?php echo $actions['action_name'];?>"/>
                <?php }else{?>
                <input type="text" class="row _minput" name='action_name' placeholder="" value=""/>
                <span class="_prompt">活动名称，主题 例如：“周年庆拼团活动”</span>
                <?php } ?>
            </div>
            
            <div class="form-group row">
                <label for="exampleInputName2" class="_label" >活动奖励:</label></div>
                <div class="form-group row" >
                <?php $actions['content'] = json_decode($actions['content'],true); $arr=$actions['content']['content']; $key=array_keys($arr); if(array_key_exists('help',$arr)){ $ke=array_pop($key); $hp=array_pop($arr); } ?>
                    <label for="exampleInputName2" class="_label" style="padding-left:5rem">前<input type="text" style="width:40%" name="lf" id="lf" placeholder="3" value="<?php echo $key[0] ?>">名：</label>
                    <input type="text" name="lf_con" id="lf_con" placeholder="奖励" value=" <?php echo $arr["$key[0]"] ?>"  readonly="readonly">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;还没优惠劵?点击<a href="javascript:;" onclick="hrefs(1)" >创建优惠劵</a><span id="lfCoupon_id"></span> <br/> 
                    <label for="exampleInputName2" class="_label" style="padding-left:5rem">前<input type="text" style="width:40%" name="tr" id="tr" placeholder="16"value="<?php echo $key[1] ?>">名：</label>
                    <input type="text" name="tr_con" id="tr_con" placeholder="奖励" value="<?php echo $arr["$key[1]"]?>"  readonly="readonly"> &nbsp;&nbsp;&nbsp;&nbsp;还没优惠劵?点击<a href="javascript:;" onclick="hrefs(2)" >创建优惠劵</a><span id="trCoupon_id"></span><br/> 
                    <label for="exampleInputName2" class="_label" style="padding-left:5rem">前<input type="text" style="width:40%" name="xh" id="xh" placeholder="64"value="<?php echo $key[2] ?>">名：</label>
                    <input type="text" name="xh_con" id="xh_con" placeholder="奖励" value="<?php echo $arr["$key[2]"]?>"  readonly="readonly"> &nbsp;&nbsp;&nbsp;&nbsp;还没优惠劵?点击<a href="javascript:;" onclick="hrefs(3)">创建优惠劵</a><span id="xhCoupon_id"></span><br/> 
                    <label for="exampleInputName2" class="_label" style="padding-left:5rem">前<input type="text" style="width:40%" name="wm" id="wm" placeholder="100"value="<?php echo $key[3] ?>">名：</label>
                    <input type="text" name="wm_con" id="wm_con" placeholder="奖励" value="<?php echo $arr["$key[3]"]?>"  readonly="readonly"> &nbsp;&nbsp;&nbsp;&nbsp;还没优惠劵?点击<a href="javascript:;" onclick="hrefs(4)" >创建优惠劵</a><span id="wmCoupon_id"></span><br/>
                    <label for="exampleInputName2" class="_label" style="padding-left:3rem">助力优惠劵：</label>
                    <input type="text" name="hp_con" id="hp_con" placeholder="奖励" value="<?php echo $hp?>"  readonly="readonly"> &nbsp;&nbsp;&nbsp;&nbsp;还没优惠劵?点击<a href="javascript:;" onclick="hrefs(5)" >创建优惠劵</a><span id="hpCoupon_id"></span><br/>
            </div>


            <div id='model'>
                <div class='form-group row'>
                    <label for="exampleInputName2" class="_label">活动开始日期:</label>
                    <?php if($actions['start_time']>0){?>
                    <input type="text" class="row _minput" name='start_time' placeholder="" value="<?php echo date('Y-m-d',$actions['start_time']);?>" onfocus="WdatePicker();" onblur=""/>
                    <?php }else{?>
                    <input type="text" class="row _minput" name='start_time' placeholder="" value="" onfocus="WdatePicker();" onblur=""/>
                    <?php }?>
                </div>
                <div class='form-group row'>
                    <label for="exampleInputName2" class="_label">活动结束日期:</label>
                    <?php if($actions['end_time']>0){?>
                    <input type="text" class="row _minput" name='end_time' placeholder="" value="<?php echo date('Y-m-d',$actions['end_time']);?>" onfocus="WdatePicker();" onblur=""/>
                    <?php }else{?>
                    <input type="text" class="row _minput" name='end_time' placeholder="" value="" onfocus="WdatePicker();" onblur=""/>
                    <?php }?>
                </div>
            </div>

            <div class='form-group row'>
                <label for="exampleInputName2" class="_label">活动介绍:</label>
                <?php if(!empty($actions)){?>
                <textarea name='intro' id="_intro" class="_textarea"><?php echo $actions['intro']; ?></textarea>
                <?php }else{?>
                <textarea name='intro' id="_intro" class="_textarea"></textarea>
                <?php }?>
            </div>
            <div class="form-group _submit_div row">
                <input name='id' type='hidden' value="<?php echo $actions['id'];?>"/>
                <input name='create' id='create' class='_button' type="button" value="预览" onclick="_submit(2);"/>
                <input name='caogao' id='caogao' class='_button' type="submit" value="保存草稿" onsubmit="return _submit(1);"/>
            </div>
        </form>
</div>

<div id='showCode' style="text-align:center;width:100%;height:100%;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#8E8E8E',endColorstr='##8E8E8E');
    background-color:rgba(0, 0,0, 0.5);position:fixed; _position:absolute; top:0;left:0; z-index:5000;display:none ">
<div  class="coupon_div" style='padding-left:2.5rem' > 
    <img width='25px'; id='down' style='float:right;margin-top:-1rem;margin-right:-1rem' src='/public/images/error1.png' >
    <form  method="post" id='forms'>
        <div class='form-group row'>
            <label  style='margin-top:4rem' >所属门店:</label>
            <input type='hidden' name='store' id='store' value='' readonly="readonly" >
            <input type='text' name='st' id='st' value='' readonly="readonly" >
        </div>
        <div class='form-group row' >
            <label for="exampleInputName2" >优惠劵名称:</label>
            <input type="text" name='coupon_name' id='coupon_name' placeholder="" value="" style="width:15rem;"/>
        </div>         
        <div class="form-group row">
            <label for="exampleInputName2" >优惠劵类型:</label>
            <select name="type_name" class='_select' id='type_name'>
                <option value="折扣券" >折扣券</option>
                <option value="现金券" >现金券</option>
                <option value="体验券" >体验券</option> 
            </select>
        </div> 
        <div class='form-group row'>
            <label for="exampleInputName2" >优惠劵折扣:</label>
            <input type="text" name="coupon_content" id="coupon_content" placeholder="折扣数" value="" style="width:5rem;"><span id='yuan'>折</span>&nbsp;&nbsp;
            店内消费满<input type='text' name='coupon_condition' id='coupon_condition' placeholder='可不填' value='' style="width:5rem;">元使用
        </div>
        <div class='form-group row'>
            <label for="exampleInputName2" >优惠劵数量:</label>
            <input type="text"  name='coupon_num' id='coupon_num' readonly="readonly"  style="width:15rem;"/>
            <span class="_prompt">-1为无限张</span>
        </div>
        <input type='hidden' name='coupon_style' value="1" >
        <div id='model'>    
            <div class='form-group row'>
                <label for="exampleInputName2" >开始日期:</label>
                <input type="text"  name='coupon_start_time' placeholder="" value="" onfocus="WdatePicker();" onblur=""/>
            </div>
            <div class='form-group row' >
                <label for="exampleInputName2" >结束日期:</label> 
                <input type="text" name='coupon_end_date' placeholder="" value="" onfocus="WdatePicker();" onblur=""/>
            </div>
            <div class='form-group row'>
                <label for="exampleInputName2" >使用截止时间:</label>              
                <input type="text"  name='coupon_end_time' placeholder="" value="" onfocus="WdatePicker();" onblur=""/>
            </div>
            
        </div>
        <div class='form-group row'>
            <label for="exampleInputName2" >优惠劵说明:</label>
        </div>
        <div class='form-group row'>
            <textarea style="margin-left:5rem;width:35rem;" name='coupon_intro' id="coupon_intro" class="_textarea" placeholder="可不写"></textarea>

        </div>
        <div class="form-group _submit_div row">
            <input name='is_action' type='hidden'   value="1">
            <input name='t' type='hidden' value='' id='t' >
            <input name='coupon_create' id='coupon_create' class='_button' type="button" value="创建"   />
        </div>
    </form>
</div>
</div>
<script type='text/javascript' src='/public/js/date/WdatePicker.js'></script>
<script type='text/javascript'>
    function del_item(obj,id){
        $(obj).parent().parent().parent().parent().remove();
        $("#items_"+id).remove();
    }
    
                $(document).ready(function () {
                        var store_id = $("#store_id").val();
                        var id = $('#type').val();
                        var str = $('#model_' + id).val();
                        $("#_intro").html(str);

                        $("#form").validate({
                            rules: {
                                store_id: {
                                    required: true,
                                    min: 1,
                                },
                                action_name: {
                                    required: true,
                                },
                                type: {
                                    required: true,
                                    number: true
                                },
                                start_time: {
                                    required: true,
                                },
                                end_time: {
                                    required: true,
                                },
                                intro: {
                                    required: true,
                                },


                            },
                            messages: {
                                store_id: {
                                    required: "请选择店铺",
                                    min: "请选择店铺",
                                },
                                action_name: {
                                    required: '请输入活动名称',
                                },
                                type: {
                                    required: '请选择活动类型',
                                },
                                start_time: {
                                    required: '请选择活动开始日期',
                                },
                                end_time: {
                                    required: '请选择活动结束日期',
                                },
                                intro: {
                                    required: '请填写活动介绍',
                                }
                            },
                            errorPlacement: function (error, element) { //指定错误信息位置
                                if (element.is(':radio') ) { //如果是radio或checkbox
                                    var eid = element.attr('name'); //获取元素的name属性
                                    error.appendTo(element.parent()); //将错误信息添加当前元素的父结点后面
                                } else {
                                    error.insertAfter(element);
                                }
                            }
                        });                    
                        //创建优惠劵
                        $("#forms").validate({
                            rules: {
                                store:{
                                    required: true,
                                    min:1
                                },
                                coupon_name: {
                                    required: true,
                                    rangelength: [0, 11],
                                },
                                coupon_num: {
                                    required: true,
                                    range: [-1, 100],
                                },
                                coupon_start_time: {
                                    required: true,
                                },
                                coupon_end_time: {
                                    required: true,
                                },
                                coupon_content: {
                                    required: true,
                                }

                            },
                            messages: {
                                store:{
                                    required: '请选择店铺',
                                    min: '请选择店铺'
                                },
                                coupon_name: {
                                    required: '请填写优惠劵名称',
                                    rangelength: '请填写字数小于11个',
                                },
                                coupon_num: {
                                    required: '请填写优惠劵数量',
                                    range: '请填写数量小于100',
                                },
                                coupon_start_time: {
                                    required: '请选择开始使用日期',
                                },
                                coupon_end_time: {
                                    required: '请选择结束使用日期',
                                },
                                coupon_content: {
                                    required: '请填写优惠劵折扣',
                                }
                            }
                        });
            });


                    function _submit(type) {
                        if (type == 1) {
                            $('#create').remove();
                        } else {
                            $('#caogao').remove();
                        }
                        var content = $("#_intro").val();
                        content = content.replace(/<br\/>/,"\n");
                        content = content.replace(/<span style=\'color:red\'>/,"");
                        content = content.replace(/<\/span>/,"");
                        content = content.replace(/\n/g, "<br/>");
                        content = content.replace(/[\d]{1,}/g, "<span style='color:red'>$&</span>");
                        $("#_intro").val(content);
                        $('#form').submit();
                    }

                    function hrefs(t) {
                        store_id = $("#store_id").val();
                        var store_name = $('#store_id option:selected').html();
                        if(store_id<1){
                            alert('请先选择店铺');
                            return;
                        }
                        if (t == 1) {
                            num = $("#lf").val();
                            if(num<1){
                                alert('请先填写所需优惠劵数量');
                                return;
                            }
                        }
                        if (t == 2) {
                            var lf = $("#lf").val();
                            var tr = $("#tr").val();
                            if(tr<1){
                                alert('请先填写所需优惠劵数量');
                                return;
                            }
                            num = (tr - lf);
                            if(num<1){
                                alert('请按顺序创建优惠劵');
                                return;
                            }
                        }
                        if (t == 3) {
                            tr = $("#tr").val();
                            var xh = $("#xh").val();
                            if(xh<1){
                                alert('请先填写所需优惠劵数量');
                                return;
                            }
                            num = (xh - tr);
                            if(num<1){
                                alert('请按顺序创建优惠劵');
                                return;
                            }
                        }
                        if (t == 4) {
                            xh = $("#xh").val();
                            var wm = $("#wm").val();
                            if(wm<1){
                                alert('请先填写所需优惠劵数量');
                                return;
                            }
                            num = (wm - xh);
                            if(num<1){
                                alert('请按顺序创建优惠劵');
                                return;
                            }
                        }
                        if (t == 5) {
                            num = (-1);
                        }
                        $('#coupon_num').val(num);
                        $('#store').val(store_id);
                        $('#st').val(store_name);
                        $('#t').val(t);
                        if(t!=1){
                            $('#coupon_name').val('');
                            $('#coupon_content').val('');
                            $('#coupon_condition').val('');
                        }
                        $('#showCode').show();
                    }
                    //关闭创建优惠劵
                    $('#down').click(function(){
                        $('#showCode').hide();
                    });
                    //创建优惠劵
                    $("#type_name").change(function () {
                    var num = '';
                    if ($("#type_name").val() == "现金券") {
                        num = 1;
                    } else if ($("#type_name").val() == "折扣券") {
                        num = 0;
                    } else {
                        num = 2;
                    }
                    $.ajax({
                        url: "/home/coupon/ajax?num=" + num,
                        async: true,
                        success: function (data) {
                            if (data == "false") {
                                return;
                            } else if (data == 1) {
                                $('#coupon_content').attr('placeholder', "金额");
                                $("#yuan").html('元');
                            } else if (data == 0) {
                                $('#coupon_content').attr('placeholder', "折扣数");
                                $("#yuan").html('折');
                            } else if (data == 2) {
                                $('#coupon_content').attr('placeholder', "金额");
                                $("#yuan").html('元');
                            }
                        }
                    });
                });
                if ($("#type_name").val() == "现金券") {
                    $('#coupon_content').attr('placeholder', "金额");
                    $("#yuan").html('元');
                } else if ($("#type_name").val() == "折扣券" || $("#type_name").val() == '') {
                    $('#coupon_content').attr('placeholder', "折扣数");
                    $("#yuan").html('折');
                } else {
                    $('#coupon_content').attr('placeholder', "项目名");
                    $("#yuan").html('');
                }

                $('#coupon_create').click(function(){
                    $.ajax({
                        cache: true,
                        type: "POST",
                        url:"/home/coupon/submit",
                        data:$('#forms').serialize(),
                        async: false,
                        success: function(data) {
                            if(data<1){
                                alert('创建失败！');
                            }else{
                                $('#showCode').hide();
                                if(data==1){
                                   lf(); 
                                }
                                if(data==2){
                                    tr();
                                }
                                if(data==3){
                                    xh();
                                }
                                if(data==4){
                                    wm();
                                }
                                if(data==5){
                                    hp();
                                }
   
                            }
                        }
                    });
                });
                function lf(){
                    store_id = $('#store_id').val();
                    lf = $("#lf").val();
                    num = lf;
                    $.ajax({
                        url: "/home/coupon/action?num=" + num + "&store_id=" + store_id,
                        async: true,
                        success: function (data) {
                            if (data == 'false') {
                                number = -1;
                                return;
                            }
                            var html = "";
                            data = eval('(' + data + ')');
                            var name = data.content + data.type_name;
                            html += '<input type="hidden" name="lfCoupon_id"  value=" ';
                            html += data.id;
                            html += '" />';
                            $("#lf_con").val(name);
                            $("#lfCoupon_id").html(html);
                        }
                    });     
                }
                function tr(){
                    store_id = $('#store_id').val();
                    lf = $("#lf").val();
                    tr = $("#tr").val();
                    num = (tr - lf);
                    $.ajax({
                        url: "/home/coupon/action?num=" + num + "&store_id=" + store_id,
                        async: true,
                        success: function (data) {
                            if (data == 'false') {
                                number = -1;
                                return;
                            }
                            var html = "";
                            data = eval('(' + data + ')');
                            var name = data.content + data.type_name;
                            html += '<input type="hidden" name="trCoupon_id"  value=" ';
                            html += data.id;
                            html += '" />';
                            $("#tr_con").val(name);
                            $("#trCoupon_id").html(html);

                        }
                    });
                }
                function xh(){
                    store_id = $('#store_id').val();
                    tr = $("#tr").val();
                    xh = $("#xh").val();
                    num = (xh - tr);
                    $.ajax({
                        url: "/home/coupon/action?num=" + num + "&store_id=" + store_id,
                        async: true,
                        success: function (data) {
                            if (data == 'false') {
                                number = -1;
                                return;
                            }
                            var html = "";
                            data = eval('(' + data + ')');
                            var name = data.content + data.type_name;
                            html += '<input type="hidden" name="xhCoupon_id"  value=" ';
                            html += data.id;
                            html += '" />';
                            $("#xh_con").val(name);
                            $("#xhCoupon_id").html(html);

                        }
                    });
                }
                function wm(){
                    store_id = $('#store_id').val();
                    xh = $("#xh").val();
                    wm = $("#wm").val();
                    num = (wm - xh);
                    $.ajax({
                        url: "/home/coupon/action?num=" + num + "&store_id=" + store_id,
                        async: true,
                        success: function (data) {
                            if (data == 'false') {
                                number = -1;
                                return;
                            }
                            var html = "";
                            data = eval('(' + data + ')');
                            var name = data.content + data.type_name;
                            html += '<input type="hidden" name="wmCoupon_id"  value=" ';
                            html += data.id;
                            html += '" />';
                            $("#wm_con").val(name);
                            $("#wmCoupon_id").html(html);

                        }
                    });
                }
                function hp(){
                    store_id = $('#store_id').val();
                    num = (-1);
                    $.ajax({
                        url: "/home/coupon/action?num=" + num + "&store_id=" + store_id,
                        async: true,
                        success: function (data) {
                            if (data == 'false') {
                                number = -1;
                                return;
                            }
                            var html = "";
                            data = eval('(' + data + ')');
                            var name = data.content + data.type_name;
                            html += '<input type="hidden" name="hpCoupon_id"  value=" ';
                            html += data.id;
                            html += '" />';
                            $("#hp_con").val(name);
                            $("#hpCoupon_id").html(html);

                        }
                    });
                }


    // 选择活动模式
    $("#type").change(function () {
        var id = $('#type').val();
        var str = $('#model_' + id).val();
        $("#_intro").html(str);
        if (id != 2) {
            var link = $('#model_type_'+id).attr("url");
            window.location.href = '/home/action/create?model_id='+id+'&model='+link;
            return;
        }
        window.location.reload();
    });

</script>
<style>.error{padding-left:2rem}</style>
</div>
<div class="_line"></div>
<div class="_footer">
    ©2015-<?php echo date('Y');?> All Rights Reserved ( 京ICP备15010043号 )
</div>
</div>
<div id='mask_layer' style="text-align: center;width:100%;height:100%;overflow:hidden;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#8E8E8E',endColorstr='##8E8E8E');
    background-color:rgba(255, 255, 255, 0.4);position:fixed; _position:absolute; top:0;left:0; z-index:5000;display:none ">
    <div style="padding-top: 20%"><h1><b>loading<span id="_loading"></span></b></h1></div>
</div>
    </body>
</html>